package problems.daily;

/**
 * <p></p>
 *
 * @author habitplus
 * @since 2023/3/2 9:23
 */
public class DT_MS05_02 {
    public String printBin(double num) {
        char[] chs = String.valueOf(num).toCharArray();
        int n = chs.length;
        final int N = 10;

        int b = 5;
        int d = 0;
        int a;

        StringBuilder sb = new StringBuilder("0.");
        for (int i = 0; i < N; ++i) {
            a = d * 10 + (i + 2 < n ? chs[i + 2] - '0' : 0);

            if (a >= b) {
                sb.append(1);
                d = a - b;
                if (a == b && i + 2 == n - 1) break;
            } else {
                sb.append(0);
                d = a;
            }

            b *= 5;
        }
        return d == 0 ? sb.toString() : "ERROR";
    }

    public static void main(String[] args) {
//        long num = 100;
//        int a = num + 2;
//        System.out.println(a);

        int num = 50;
        int a = 0;

        // num = num++ * 2;
        // 等同于
        int temp = num;
        num = temp + 1;
        num = temp * 2;
        System.out.println(num + " " + a);
    }
}
